

import java.io.DataInputStream;
import org.json.JSONArray;
import org.json.JSONObject;

public class MusicLastFm {
	
	public MusicLastFm(String text)throws Exception{
		framework obj=new framework();
		@SuppressWarnings("deprecation")
		String line= (new DataInputStream(obj.gsearch("http://ws.audioscrobbler.com/2.0/?method=track.search&format=json&api_key=b25b959554ed76058ac220b7b2e0a026&format=json&"
			    + "track="+ text.replace(" ", "+"))).readLine());
		getMusiclinks(line);
	}
	public void getMusiclinks(String line) throws Exception
    {
		
 	   JSONObject json = new JSONObject(line);
		JSONObject gson=json.getJSONObject("results");
		JSONObject kson=gson.getJSONObject("trackmatches");
		JSONArray lson=kson.getJSONArray("track");
		
		int size=lson.length();
				for(int i=0;i<size;i++)
				{
					JSONObject nson=lson.getJSONObject(i);
			String sample=nson.getString("url")	;		
			System.out.println(sample);
		}
    }
}
